"""
start:开启线程
time.sleep():等待几秒
join():阻塞线程，互斥锁# 创建锁 hreading.Lock()# 锁定 mutex.acquire()# 释放 mutex.release()
setDaemon(True)  daemon=True  守护主线程
"""

from threading import Thread
import threading
import time

sum_num = 0

s = threading.Lock()


def sing(count):
    global sum_num
    s.acquire()
    for i in range(count):
        time.sleep(0.2)
        print("我在数数字-", i)
    for i in range(2000000):
        sum_num += 1
    print("sing==", sum_num)
    s.release()


def dancing(count):
    global sum_num
    s.acquire()
    for i in range(count):
        time.sleep(0.2)
        print("我在转圈-", i)
    for i in range(2000000):
        sum_num += 1
    print("sing==", sum_num)
    s.release()


if __name__ == '__main__':
    Sing = Thread(target=sing, args=(5,), name="sing")  # ,daemon=True
    Dancing = Thread(target=dancing, kwargs={'count': 5}, name="dancing")  # ,daemon=True

    Sing.start()
    # Sing.join()
    Dancing.start()
    # Sing.setDaemon(True)
    # Dancing.setDaemon(True)
    time.sleep(0.5)
    print("我是主线程，我不想等子线程结束")
